# -*- coding: utf-8 -*-
# @Time    : 2023/10/12 13:41
# @Author  : floraachy
# @File    : user_manage_api.py.py
# @Software: PyCharm
# @Desc:

# 本地应用/模块导入
from case_utils.base_request import BaseRequest
from case_utils.tools import url_handle
from interface.login_api import login_api


class UserManageApi:
    """
    用户管理模块相关api
    """

    def __init__(self, host, user, pwd):
        self.host = host
        self.cookies = login_api(host=self.host, user=user, pwd=pwd).cookies

    def reset_login_times(self, user_id: str):
        """
        恢复禁密账号
        :param user_id: 用户id
        """
        req_data = {
            "title": "恢复禁密账号",
            "url": url_handle(host=self.host, url=f"/admins/users/{user_id}/reset_login_times"),
            "method": "POST",
            "headers": {"Content-Type": "application/json;charset=UTF-8"},
            "request_type": "json",
            "cookies": self.cookies
        }
        return BaseRequest.send_request(req_data)
